package com.edu.zju.scs.panacea.mapper.resource;

import com.edu.zju.scs.panacea.entity.resource.Package;
import com.edu.zju.scs.panacea.entity.resource.PackageRelLoc;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: Yue Liang
 * @Date: 2018-12-27 17:45
 */

@Repository
public interface PackageRelLocMapper {
    @Insert({
            "<script>",
            "insert into res_package_rel_loc(package_id, loc_id) values ",
            "<foreach collection='locIds' item='item' index='index' separator=','>",
            "(#{packageId}, #{item})",
            "</foreach>",
            "</script>"})
    long insertPackageRelLoc(@Param("packageId") Long packageId, @Param("locIds")List<Long> locIds);


    @Delete("DELETE FROM res_package_rel_loc where package_id = #{packageId}")
    long deletePackageRelLoc(Long packageId);


    @Select("select loc_id FROM res_package_rel_loc where package_id = #{packageId}")
    List<Long> selectLocsByPackage(Long packageId);
}
